package com.itheima.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.DTO.CheckItemDTO;
import com.itheima.DTO.CheckItemPageQueryDTO;
import com.itheima.VO.CheckItemVO;
import com.itheima.common.entity.PageResult;
import com.itheima.mapper.CheckitemMapper;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckitemService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-12-18
 */
@Service
public class CheckitemServiceImpl extends ServiceImpl<CheckitemMapper, CheckItem> implements CheckitemService {
    @Autowired
    private CheckitemMapper checkitemMapper;


    @Override
    public PageResult findPage(CheckItemPageQueryDTO checkItemPageQueryDTO) {
        PageHelper.startPage(checkItemPageQueryDTO.getCurrentPage(),checkItemPageQueryDTO.getPageSize());
        Page<CheckItemVO> page = checkitemMapper.findPage(checkItemPageQueryDTO);
        return new PageResult(page.getTotal(),page.getResult());
    }

    @Override
    public void addCheckItem(CheckItemDTO checkItemDTO) {
        checkitemMapper.addCheckItem(checkItemDTO);
    }

    @Override
    public CheckItemVO findGetById(Integer id) {
        return checkitemMapper.findGetById(id);
    }

    @Override
    public void edit(CheckItemDTO checkItemDTO) {
        checkitemMapper.edit(checkItemDTO);
    }

    @Override
    public void deleteItemById(Integer id) {
        checkitemMapper.deleteItemById(id);
    }

    @Override
    public List<CheckItem> findAll() {
        return checkitemMapper.findAll();
    }


}
